﻿using FluentValidation;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using  Wips.AppService.Publisher.Requests;

namespace   Wips.AppService.Publisher.Requests
{
    /// <summary>
    /// 注册子服务
    /// </summary>
    public class RegisterAgentServerRequest : IRequest<string>
    {
        /// <summary>
        /// 服务key
        /// </summary>
        public string ServerKey { get; set; } = "";

        /// <summary>
        /// 服务名称
        /// </summary>
        public string ServerName { get; set; } = "";


        /// <summary>
        /// 子服务地址
        /// </summary>
        public string AgentAddress { get; set; } = "";


    }
}

/// <summary>
/// 校验
/// </summary>
public class RegisterAgentServerRequestValidator : AbstractValidator<RegisterAgentServerRequest>
{
    /// <summary>
    /// 
    /// </summary>
    public RegisterAgentServerRequestValidator()
    {
        RuleFor(p => p.ServerKey)
            .Must(p => !string.IsNullOrEmpty(p))
            .WithMessage("ServerKey不能为空");

        RuleFor(p => p.ServerName)
            .Must(p => !string.IsNullOrEmpty(p))
            .WithMessage("ServerName不能为空");


        RuleFor(p => p.ServerName)
         .Must(p => !string.IsNullOrEmpty(p))
         .WithMessage("AgentAddress不能为空");



    }
}